<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib prefix="fmt" 
           uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Insert title here</title>
	<script type="text/javascript" src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>
	<p style="text-align:center">${sessionScope.name}的订单</p>
	<a href="${pageContext.request.contextPath }/user/toConsumeBase"><button>首页</button></a>
	<table width="100%" border=1 style="text-align:center">
		<tr>
			<td>订单编号</td>
			<td>订单状态</td>
			<td>收货人姓名</td>
			<td>联系电话</td>
			<td>收货地址</td>
			<td>操作</td>
		</tr>
		<c:if test="${enhanceList!=null}">
			<c:forEach items="${enhanceList}" var="enhance">
				<tr>
					<td class="code">${enhance.myOrder.code}</td>
					<td class="status">${enhance.orderStatus.describe}</td>
					<td>${enhance.shippingAddress.name}</td>
					<td>${enhance.shippingAddress.phonenum}</td>
					<td>${enhance.shippingAddress.province}${enhance.shippingAddress.city}${enhance.shippingAddress.address}(${enhance.shippingAddress.addressalias})</td>
					<td>
						<a class="recall" href="${pageContext.request.contextPath }/user/recallOrder?myOrderId=${enhance.myOrder.id}&myOrderStatus=${enhance.orderStatus.describe}">撤单</a>
						<a style="display: none;" class="pay" href="${pageContext.request.contextPath }/user/payOrder?myOrderId=${enhance.myOrder.id}">付款</a>
						<a style="display: none;" class="receive" href="${pageContext.request.contextPath }/user/receiveOrder?myOrderId=${enhance.myOrder.id}">收货</a>
					</td>
				</tr>
			</c:forEach>
		</c:if>
	</table>
	<c:if test="${outTime}">
			<script>
				(function()
				{
					alert("收货时间超过七天无法直接退货,如需退货请联系客服")
				})();
			</script>
		</c:if>
	<script>
		$(document).ready(function(){
			$.each($(".status"),function(index,content){
				if($(content).text()=="撤单")
				{
					$(".recall").eq(index).hide();
					return;
				}
				if($(content).text()=="未付款")
				{
					$(".pay").eq(index).show();
					return;
				}
				if($(content).text()=="待收货")
				{
					$(".receive").eq(index).show();
					return;
				}
			})
			
		})
		$(document).ready(function(){
			$(".code").click(function(){
				window.open("${pageContext.request.contextPath }/user/orderDetails?code="+$(this).text(),"_self");
			})	
		})
	</script>
</body>
</html>